<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        function error_detail(id){
            var url = 'index.php?c=appLog&m=log_detail&id='+id;
            var param = {};
            common_ajax(url, param, function (data){
                if(data.errorCode == 0) {
                    var res = data.responseData.msg;
                    $('#error_result').html(formatJson(res));

                    $('#error_detail').modal('show');
                    return true;
                }else{
                    alert(data.errorMsg);
                }
            });
        }
        var formatJson = function (json, options) {
            var reg = null, formatted = '', pad = 0, PADDING = '    ';
            options = options || {};
            options.newlineAfterColonIfBeforeBraceOrBracket = (options.newlineAfterColonIfBeforeBraceOrBracket === true) ? true : false;
            options.spaceAfterColon = (options.spaceAfterColon === false) ? false : true;
            if (typeof json !== 'string') {
                json = JSON.stringify(json);
            } else {
                json = JSON.parse(json);
                json = JSON.stringify(json);
            }
            reg = /([\{\}])/g;
            json = json.replace(reg, '\r\n$1\r\n');
            reg = /([\[\]])/g;
            json = json.replace(reg, '\r\n$1\r\n');
            reg = /(\,)/g;
            json = json.replace(reg, '$1\r\n');
            reg = /(\r\n\r\n)/g;
            json = json.replace(reg, '\r\n');
            reg = /\r\n\,/g;
            json = json.replace(reg, ',');
            if (!options.newlineAfterColonIfBeforeBraceOrBracket) {
                reg = /\:\r\n\{/g;
                json = json.replace(reg, ':{');
                reg = /\:\r\n\[/g;
                json = json.replace(reg, ':[');
                }
            if (options.spaceAfterColon) {
                reg = /\:/g;
                json = json.replace(reg, ':');
                }
            (json.split('\r\n')).forEach(function (node, index) {
                var i = 0,
                    indent = 0,
                    padding = '';
                if (node.match(/\{$/) || node.match(/\[$/)) {
                    indent = 1;
                    } else if (node.match(/\}/) || node.match(/\]/)) {
                    if (pad !== 0) {
                        pad -= 1;
                        }
                    } else {
                    indent = 0;
                    }
                for (i = 0; i < pad; i++) {
                    padding += PADDING;
                    }
                formatted += padding + node + '\r\n';
                pad += indent;
                }
            );
            return formatted;
        };
        $("#error_detail").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
        });
    </script>
    <body class="gray-bg">
    <div class="wrapper wrapper-content ">

        <div class="modal fade" id="error_detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog" style="width: 60%;">
                <div class="modal-content">
                    <style>
                        pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; display: inline-grid !important; width:100%;}
                        .string { color: green; }
                        .number { color: darkorange; }
                        .boolean { color: blue; }
                        .null { color: magenta; }
                        .key { color: red; }
                    </style>
                    <div class="tab-pane active">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h2 class="modal-title">log信息</h2>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <pre id="error_result"></pre>

                                <div class="clearfix"></div>
                            </div>
                            <div class="clearfix"></div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5><?php echo $pageTitle; ?></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">

                            <form class="form-horizontal" id="f_form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr class="info">
                                        <th>log信息</th>
                                        <th>时间</th>
                                        <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach($appLogList as $appError) {?>
                                        <tr>
                                            <td><?php echo $appError["desc"]; ?></td>
                                            <td><?php echo date("Y-m-d H:i:s", $appError["add_time"]); ?></td>
                                            <td>
                                                <a href="javascript:void(0)" onclick="error_detail(<?php echo $appError["id"];?>)" class="btn btn-white btn-sm">详  细</a>
                                            </td>
                                        </tr>
                                    <?php }?>
                                    </tbody>
                                </table>
                                <div class="set_page">
                                    <?php echo $multipage; ?>
                                    <div class="clearfix"></div>
                                </div>
                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>


<?php  include VIEWPATH.'common/footer.php';  ?>